[SPARK-4379][Core] Change Exception to SparkException in checkpoint#3241
[SPARK-4379][Core] Change Exception to SparkException in checkpoint#3241zsxwing wants to merge 1 commit intoapache:masterfrom zsxwing:SPARK-4379
Conversation
|
Test build #23304 has started for PR 3241 at commit
|
|
Yes, throwing |
|
Test build #23304 has finished for PR 3241 at commit
|
|
Test PASSed. |
|
Does this definitely change the bytecode signature? If so, I wonder why we don't get a compatiblity warning. |
|
We're throwing a more specific exception class, so I guess that caller code doesn't need to change: if the old caller code caught I think this compatibility concern is moot, though, since scala> import java.io.IOException
import java.io.IOException
scala> class A {
| def foo() {
| throw new IOException("error!")
| }
| }
defined class A
scala> :javap -s A
Compiled from "<console>"
public class A {
public void foo();
Signature: ()V
public A();
Signature: ()V
}
scala> class B {
| @throws[IOException]
| def foo() {
| throw new IOException("error!")
| }
| }
defined class B
scala> :javap -s B
Compiled from "<console>"
public class B {
public void foo() throws java.io.IOException;
Signature: ()V
public B();
Signature: ()V
} |
|
Hm, I may have learned something today. I don't think it is even in the signature of the method when scalac compiles it. See http://www.scala-lang.org/old/node/106 or http://engineering.richrelevance.com/exceptional-exceptions/#advanced Sure enough |
|
Does that mean if we went the other way (i.e. changing it from |
|
Exception won't be in the method signature. scala> import java.io.IOException
import java.io.IOException
scala> class A {
| @throws[IOException]
| def foo() {
| throw new IOException("error!")
| }
|
| def bar(): Unit = {
| foo()
| }
| }
defined class A
scala> :javap -private -c A
Compiled from "<console>"
public class A extends java.lang.Object{
public void foo() throws java.io.IOException;
Code:
0: new #9; //class java/io/IOException
3: dup
4: ldc #11; //String error!
6: invokespecial #15; //Method java/io/IOException."<init>":(Ljava/lang/String;)V
9: athrow
public void bar();
Code:
0: aload_0
1: invokevirtual #20; //Method foo:()V
4: return
public A();
Code:
0: aload_0
1: invokespecial #22; //Method java/lang/Object."<init>":()V
4: return
}In the |
|
I'm sorry that I should have been clearer when I said the breaking change. I'm worried about the following case: It breaks such case. However, I think few people will write such code. Therefore, does Spark view such change as a breaking change? |
|
I think this should be ok. Because we didn't really document the exception, it is not strictly part of the contract. |
|
I'm merging this in master. |
It's better to change to SparkException. However, it's a breaking change since it will change the exception type. Author: zsxwing <zsxwing@gmail.com> Closes #3241 from zsxwing/SPARK-4379 and squashes the following commits: 409f3af [zsxwing] Change Exception to SparkException in checkpoint (cherry picked from commit dba1405) Signed-off-by: Reynold Xin <rxin@databricks.com>
It's better to change to SparkException. However, it's a breaking change since it will change the exception type.